﻿using DFGK_WMS.IRepository;
using DFGK_WMS.Model.Models;

namespace DFGK_WMS.WebAPI.Controllers.Result
{
    public static class BaseResult
    {
        public static ApiResult Result(object data,string message,string code,int count=0)
        {
            ApiResult result = new ApiResult();
            result.code = code;
            result.message = message;
            result.data = data;
            result.count = count;
            return result;
        }
        public static ApiResult Result(object data, string code, int count)
        {
            ApiResult result = new ApiResult();
            result.code = code;
            result.data = data;
            result.count = count;
            return result;
        }
        public static ApiResult Result(object data, string code)
        {
            ApiResult result = new ApiResult();
            result.code = code;
            result.data = data;
            return result;
        }
        public static ApiResult Result(string code, string message)
        {
            ApiResult result = new ApiResult();
            result.code = code;
            result.message= message;
            return result;
        }
        public static void AddLog(ILogRepository logRepository,int LogType,int ActionType,string UserName,string RealName,string Description,string Ipaddress)
        {
            TLog logg = new TLog();
            logg.LogType = LogType;
            logg.ActionType = ActionType;
            logg.UserName = UserName;
            logg.RealName = RealName;
            logg.Description = Description;
            //获取前端IP地址
            logg.Ipaddress = Ipaddress;

            try
            {
                logRepository.AddTLod(logg);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
